<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	template="/customers/customers-frame.xhtml">

	<ui:param name="pageTitle" value="#{messages['page.customers.edit.title']}" />

	<ui:define name="subheader">#{messages['page.customers.edit.subheader']} #{customer.firstname} #{customer.lastname}</ui:define>

	<ui:define name="main">
		<h:form id="personEditForm">
			<rich:panel id="personEditPanel">
				<f:facet name="header">
					<h:outputText value="#{messages['page.customers.show.panel.title']}" />
				</f:facet>

				<s:decorate id="personFirstnameDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.firstname']}:</ui:define>
					<h:inputText required="true" id="firstname"
						value="#{customer.firstname}" style="width:300px;" />
				</s:decorate>

				<s:decorate id="personLastnameDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.lastname']}:</ui:define>
					<h:inputText value="#{customer.lastname}" required="true"
						id="lastname" style="width:300px;" />
				</s:decorate>

				<s:decorate id="personBirthdayDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.birthday']}:</ui:define>
					<rich:calendar datePattern="#{messages['formatter.date.long']}"
						value="#{customer.birthday}" required="true" id="birthday"
						style="width:300px;" />
				</s:decorate>

				<s:decorate id="personGenderDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.gender']}:</ui:define>

					<h:selectOneMenu value="#{customer.gender}" required="true"
						id="genderOption" style="width:300px;">
						<s:selectItems var="g" value="#{gender}" label="#{g.label}"
							id="gender" />
						<s:convertEnum />
					</h:selectOneMenu>
				</s:decorate>

				<s:decorate id="peselLastnameDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.pesel']}:</ui:define>
					<h:inputText value="#{customer.pesel}" required="true" id="pesel"
						style="width:300px;" />
				</s:decorate>

                <s:decorate id="personPeselDecoration" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.pesel']}:</ui:define>
					<h:inputText value="#{customer.pesel}" required="true" id="pesel"
						style="width:300px;"
                        validatorMessage="#{messages['validator.pesel']}">
                        <f:validator validatorId="peselValidator"/>
                    </h:inputText>
				</s:decorate>

				<s:decorate id="personStreetDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.address.street']}:</ui:define>
					<h:inputText value="#{customer.address.street}" required="true"
						id="street" style="width:300px;" />
				</s:decorate>

				<s:decorate id="personPostcodeDecoration"
					template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.address.postcode']}:</ui:define>
					<h:inputText value="#{customer.address.postcode}" required="true"
						id="postcode" style="width:300px;"
                        validatorMessage="#{messages['validator.postdode']}">
                        <f:validator validatorId="postalValidator"/>
                    </h:inputText>
				</s:decorate>

				<s:decorate id="personCityDecoration" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['person.address.city']}:</ui:define>
					<h:inputText value="#{customer.address.city}" required="true"
						id="city" style="width:300px;" />
				</s:decorate>

				<s:decorate template="/layout/buttonbox.xhtml" id="personButtonBox">
					<s:button action="#{personBean.refresh(customer)}"
						value="#{messages['general.back']}" view="/customers/index.xhtml"
						id="back" />
					<h:commandButton action="#{personBean.update(customer)}"
						value="#{messages['general.save']}" id="save" />
				</s:decorate>
			</rich:panel>
		</h:form>
	</ui:define>
</ui:composition>
